import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

export const LayoutChildren: Array<RouteRecordRaw>=[
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/home/index.vue'),
    meta: {  id:"0",title: '工作台', icon: 'iconfont icon-gongzuotai'}
  },
  {
    path: '/page',
    name: 'page',
    component: () => import('../views/page/index.vue'),
    meta: { id:"1",title: ' 页面管理', icon: 'iconfont icon-yemian'}
  },
  {
    path: '/article',
    name: 'article',
    component: () => import('../views/article/index.vue'),
    meta: {  id:"2",title: '文章管理', icon:  'iconfont icon-bianjiwenzhang_huaban'},
    children:[
      {
        path: '/article/allArticles',
        name: 'allArticles',  
        component: () => import('../views/article/all-articles.vue'),
        meta: { id:"3",title: '所有文章', icon: 'iconfont icon-bianjiwenzhang_huaban'},
      },
      {
        path: '/article/classify',
        name: 'classify',
        component: () => import('../views/article/classify.vue'),
        meta: {  id:"4",title: '分类管理', icon: 'iconfont icon-bianjiwenzhang_huaban'},
      },
      {
        path: '/article/label',
        name: 'label',
        component: () => import('../views/article/label.vue'),
        meta: {id:"5", title: '标签管理', icon: 'iconfont icon-bianjiwenzhang_huaban'},
      }
    ]
  },
  {
    path: '/knowledge',
    name: 'knowledege',
    component: () => import('../views/knowledge/index.vue'),
    meta: {  id:"6",title: '知识小册', icon: 'iconfont icon-bianjiwenzhang_huaban'}
  },
  {
    path: '/posters',
    name: 'posters',
    component: () => import('../views/posters/index.vue'),
    meta: {id:"7", title: '海报管理', icon: 'iconfont icon-haibao'}
  },
  {
    path: '/comment',
    name: 'comment',
    component: () => import('../views/comment/index.vue'),
    meta: { id:"8",title: '评论管理', icon: 'iconfont icon-pinglun'}
  },
  {
    path: '/mail',
    name: 'mail',
    component: () => import('../views/mail/index.vue'),
    meta: {id:"9", title: '邮件管理', icon: 'iconfont icon-youjian'}
  },
  {
    path: '/file',
    name: 'file',
    component: () => import('../views/file/index.vue'),
    meta: { id:"10",title: '文件管理', icon: 'iconfont icon-wenjianjia'}
  },
  {
    path: '/searchRecord',
    name: 'searchRecord',
    component: () => import('../views/searchRecord/index.vue'),
    meta: {id:"11", title: '搜索记录', icon: 'iconfont icon-sousuo'}
  },
  {
    path: '/visitStatistics',
    name: 'visitStatistics',
    component: () => import('../views/visitStatistics/index.vue'),
    meta: { id:"12",title: '访问统计', icon: 'iconfont icon-tongjifenxi-xiangmubiaogetongji'}
  },
  {
    path: '/userControl',
    name: 'userControl',
    component: () => import('../views/userControl/index.vue'),
    meta: { id:"13",title: '用户管理', icon: 'iconfont icon-yonghu'}
  },
  {
    path: '/systemSetup',
    name: 'systemSetup',
    component: () => import('../views/systemSetup/index.vue'),
    meta: {id:"14", title: '系统设置', icon: 'iconfont icon-shezhi'}
  },
  {
    path: '/personalCenter',
    name: 'personalCenter',
    component: () => import('../views/personal-center/index.vue')
  }
]

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'layout',
    redirect:"/home",
    component: () => import('../views/layout/index.vue'),
    children:LayoutChildren
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register/index.vue')
  },
  {
    path: '/neweditor',
    name: 'neweditor',
    component: () => import('../views/neweditor/index.vue')
  },
  {
    path: '/newArticles',
    name: 'newArticles',
    component: () => import('../views/newArticles/index.vue')
  },
  {
    path: '/newPage',
    name: 'newPage',
    component: () => import('../views/newPage/index.vue')
  },
  {
    path: '/editor/:id',
    name: 'editor',
    component: () => import('../views/editor/index.vue')
  },
  {
    path: '/addeditor',
    name: 'addeditor',
    component: () => import('../views/addEditor/index.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
